package com.agile.leetcode.hot.easy;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/7/16 10:10
 */
public class twoNumSub {
    public static void main(String[] args) {
        int[]  arr={2,7,11,45,15,3};
        System.out.println(Arrays.toString(getSub(arr, 26)));
    }
    public  static int[] getSub(int[] arr,int target){
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < arr.length; i++) {
            if (map.containsKey(target-arr[i])){
                return new int[]{map.get(target - arr[i]),i};
            }
            map.put(arr[i],i);
        }
        return null;
    }
}
